home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_11 / nelson / iohandle.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-12  |  2.7 KB  |  71 lines

  1. /* ----------------------------------------------------
  2.  *  Listing 3
  3.  *
  4.  *  iohandle.h
  5.  *  Base class for handle-based IOCTL for character
  6.  *  devices and files
  7.  * ------------------------------------------------- */
  8.  
  9. #ifndef __IOHANDLE_H
  10. #define __IOHANDLE_H
  11. #include "iobase.h"
  12.  
  13. class IoctlHandle : public IoctlBase {
  14. protected:
  15.     unsigned handle_info( int );      //get info
  16.     virtual void IoctlError(int);
  17.     IoctlHandle( int handle );      //constructor 1
  18.     IoctlHandle( const char *path );  //constructor 2
  19.     int _handle;        //validated handle
  20.     int _pathused;   //!0 if Init( char *) called
  21.     unsigned _info;     //handle info word
  22. public:
  23.     static IoctlHandle *Init( int handle );
  24.     static IoctlHandle *Init(const char *);
  25.     ~IoctlHandle();     //destructor
  26.  
  27.     //Format of handle information word ....
  28.     enum file_info   {
  29.     drive_number = 0x003f, //bits 0-5 =drive#
  30.                            //(0-based, A=0)
  31.                       //= drive containing the file.
  32.     cleared = 0x0040,  //bit 6=1 if file cleared
  33.                        // (i.e. not written to)
  34.     file_bit = 0x0080,    //bit 7=0 if a file
  35.     fixed = 0x0800,   //bit 11=1, media not removable
  36.     noInherit = 0x1000,  //bit 12=1, no inherit (?)
  37.     noCommit = 0x4000,  //bit 14=1, Date/time not set
  38.             //on handle close operation
  39.     remote = 0x8000     //bit 15=1 if file remote
  40.     };
  41.     enum device_info {
  42.     std_in = 0x0001,    //bit 0=1 if std input
  43.     std_out = 0x0002,   //bit 1=1 if std output
  44.     std_nul = 0x0004,   //bit 2=1 if NUL device
  45.     std_clk = 0x0008,   //bit 3=1 if CLOCK device
  46.     use_int29h = 0x0010,  //use int 29h for single
  47.                           //char text output.....
  48.     binary = 0x0020,      //bit 5=0 if ASCII,
  49.                           // =1 if binary
  50.     eof = 0x0040,       //bit 6=0 if at EOF on input
  51.     device_bit = 0x0080,    //bit 7=1 if a device
  52.     network = 0x1000,  //bit 12=1 if network device
  53.     ioctl = 0x4000  //bit 14=1 if driver can
  54.                     //process IOCTL strings via
  55.                     //subfunctions 02h & 03h
  56.     };
  57.     int readHandle(void) { return _handle; }
  58.     int isFile( void )
  59.         { return !(file_bit & _info);  }
  60.     int isDevice( void )
  61.         { return device_bit & _info;   }
  62.     unsigned handleInfo(void)   //get & refresh _info
  63.         {   _info = handle_info( _handle );
  64.             return _info;       }
  65.     int inputStatus( void );  //!0=ready, 0=not
  66.     int outputStatus( void ); //!0=ready, 0=not
  67.     int isRemote(void);  //File/device handle remote?
  68. };  //.... end class IoctlHandle
  69. #endif //__IOHANDLE_H
  70. /* ----- End of File ------------------------------- */
  71.